<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <ui:composition 
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../Template/AdminTemplate.xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui">

            <ui:define name="content">              
                <f:view>
                    <h:form>
                        <p:panel id="panel" header="Edit User" style="width:auto">
                            <p:column headerText="Avata">                                
                                <a href="#"><img src="#{userControl.selectedtuser.avatar}" height="100" width="70" /> </a>
                            </p:column>
                        <h:panelGrid columns="2">
                            
                            <h:outputLabel value="UserName:" for="userName" />
                            <p:inputText id="userName" value="#{userControl.selectedtuser.userName}" label="UserName">
                                <f:validateLength minimum="1"/>
                                <p:message id="msu" for="userName" display="UserName is not be empty "/>
                            </p:inputText>
                            <h:outputLabel value="Password:" for="password1" />
                            <p:password id="password1" value="#{userControl.selectedtuser.passWord}" match="password2" label="Password" required="true">
                                <f:validateLength minimum="1"/>
                                <p:message id="msp1" for="password1" display="Password is not be empty "/>
                            </p:password>
                            <h:outputLabel value="Confirm Password:" for="password2" />
                            <p:password id="password2" value="#{userControl.selectedtuser.passWord}" label="Password2" required="true">
                                <p:message id="msp2" for="password2" display="Confirm Password should match with Password"/>
                            </p:password>
                            <h:outputLabel value="Sex:" for="sex" />
                            <p:selectOneRadio id="options" value="#{userControl.selectedtuser.sex}">  
                                <f:selectItem itemLabel="Male" itemValue="true" />  
                                <f:selectItem itemLabel="Female" itemValue="false" />    
                            </p:selectOneRadio> 
                            <h:outputLabel value="FullName:" for="fullName" />
                            <p:inputText id="fullName" value="#{userControl.selectedtuser.fullName}" label="FullName" required="true">
                                <f:validateLength minimum="6"/>
                                <p:message id="msfn" for="fullName" display="FullName is not be empty "/>
                            </p:inputText>
                            
                            <h:outputLabel value="Avatar:" for="avatar" />
                            <p:fileUpload mode="advanced"  sizeLimit="1000000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" auto="true"  fileUploadListener="#{userControl.handleFileUploadEditProfile}" />  
                            <h:outputLabel value="Avatar:" for="preview" />
                            <h:commandLink id="preview" value="" ><img src="#{userControl.selectedtuser.avatar}" height="100" width="70" /></h:commandLink>
                            
                            <h:outputLabel value="Birthday:" for="birthday" />  
                            <p:calendar id="dob" binding="#{userControl.dob}" mindate="01/01/1952" value="#{userControl.selectedtuser.birthday}" navigator="true" required="true" requiredMessage="Choose your Birthday"/>                      
                            
                            <h:outputLabel value="Phone" for="phone"/>
                            <p:inputMask id="phone" value="#{userControl.selectedtuser.phone}" mask="999-999-9999" validatorMessage="Phone is not valid">
                                <p:message for="phone"/>
                            </p:inputMask>                                         
                            <h:outputLabel value="Address:" for="address" />
                            <p:inputText id="address" value="#{userControl.selectedtuser.address}" title="Address" required="true">
                                <f:validateLength minimum="1"/>
                                <p:message id="msad" for="address" display="Address must be minium 5 char "/>
                            </p:inputText>
                            <h:outputLabel value="Email:" for="email" />
                            <p:inputText id="email" value="#{userControl.selectedtuser.email}" required="true" label="Email" validatorMessage="#{userControl.selectedtuser.email} is not valid">
                                <f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
                                <p:message for="email" />
                            </p:inputText>
                            <h:outputLabel value="JoinedDate:" for="joinedDate" />
                            <p:calendar id="joineddate" maxdate="17/05/2012" mindate="01/01/1970" value="#{userControl.selectedtuser.joinedDate}" navigator="true" required="true" requiredMessage="Choose your JoinedDate"/>                      
                            <h:outputLabel value="IsAdmin:" for="isAdmin" />
                            <p:selectOneRadio id="isadmin" value="#{userControl.selectedtuser.isAdmin}">  
                                <f:selectItem itemLabel="Yes" itemValue="true" />  
                                <f:selectItem itemLabel="No" itemValue="false" />    
                            </p:selectOneRadio>
                            <h:outputLabel value="IsActive:" for="isActive" />
                            <p:selectOneRadio id="isactive" value="#{userControl.selectedtuser.isActive}">  
                                <f:selectItem itemLabel="Yes" itemValue="true" />  
                                <f:selectItem itemLabel="No" itemValue="false" />    
                            </p:selectOneRadio>
                            <h:outputLabel value="DepartmentName:" for="departmentName" />
                            <p:selectOneMenu value="#{userControl.selectedtuser.departmentName}">
                                <f:selectItem itemLabel="Select One" itemValue=""/>
                                <f:selectItem itemLabel="Manager" itemValue="Manager"/>
                                <f:selectItem itemLabel="Maketing" itemValue="MaKeting"/>
                                <f:selectItem itemLabel="IT" itemValue="IT"/>
                                <f:selectItem itemLabel="Accounting" itemValue="Accounting"/>
                                <f:selectItem itemLabel="Sales" itemValue="Sales"/>
                                <f:selectItem itemLabel="Protection" itemValue="Protection"/>
                                <p:message for="departmentName" display="Please choose Department!!!"/>
                            </p:selectOneMenu>
                            <p:commandButton value="Update" actionListener="#{userControl.update()}" update="panel" icon="ui-icon-disk"/>
                            <p:commandButton value="Reset" type="reset"/>
                        </h:panelGrid>
                        </p:panel>                                                                        
                    </h:form>
                </f:view>
            </ui:define>

            <ui:define name="bottom">
                bottom
            </ui:define>

        </ui:composition>
